import { defineStore } from 'pinia'

export const useCourseStore = defineStore('course', {
  state: () => ({
    // 课程数据，根据数据库表结构
    courses: [
      // Java相关课程
      { id: 1, subject: 1, name: 'Java基础编程课程', price: 3999, target: 1 },
      { id: 2, subject: 1, name: 'Java高级开发课程', price: 5999, target: 2 },
      { id: 3, subject: 1, name: 'AI智能应用开发(Java)', price: 8999, target: 2 },
      
      // Python相关课程
      { id: 4, subject: 2, name: 'Python入门课程', price: 2999, target: 1 },
      { id: 5, subject: 2, name: 'Python数据分析', price: 4999, target: 2 },
      { id: 6, subject: 2, name: 'AI大模型开发(Python)', price: 9999, target: 2 },
      
      // 前端相关课程
      { id: 7, subject: 3, name: '前端基础课程', price: 3999, target: 1 },
      { id: 8, subject: 3, name: '前端高级开发', price: 5999, target: 2 },
      
      // 大数据相关课程
      { id: 9, subject: 4, name: '大数据基础课程', price: 6999, target: 2 },
      { id: 10, subject: 4, name: 'AI大数据应用', price: 8999, target: 2 },
      
      // 人工智能相关课程
      { id: 11, subject: 5, name: '人工智能入门', price: 5999, target: 1 },
      { id: 12, subject: 5, name: '机器学习实战', price: 7999, target: 2 },
      
      // AI鸿蒙开发
      { id: 13, subject: 6, name: 'AI鸿蒙开发课程', price: 6999, target: 2 },
      
      // AI测试
      { id: 14, subject: 7, name: 'AI测试工程师课程', price: 5999, target: 1 },
      
      // AI运维
      { id: 15, subject: 8, name: 'AI运维工程师课程', price: 6999, target: 2 }
    ]
  }),
  
  getters: {
    // 获取所有课程
    getAllCourses: (state) => state.courses,
    
    // 根据学科ID获取相关课程
    getCoursesBySubject: (state) => (subjectId) => {
      if (!subjectId) return []
      return state.courses.filter(course => course.subject === subjectId)
    }
  },
  
  actions: {
    // 如果需要从API获取课程数据，可以在这里添加方法
    async fetchCourses() {
      // 预留从API获取课程数据的接口
      // const response = await api.getCourses()
      // this.courses = response.data
    }
  }
})